package com.maven.plugins.mybatis.generator;

import com.maven.plugins.mybatis.core.Context;
import com.maven.plugins.mybatis.core.Table;
import com.maven.plugins.mybatis.utils.FreemarkerUtils;
import com.maven.plugins.mybatis.utils.JavaBeanUtils;

/**
 * domain 模板渲染工具
 * @author : fredia
 * @email : trumpey@163.com
 * @since : 2017年11月23日
 * @version : v0.0.1
 */
public class DomainGenerator {
	
	@SuppressWarnings("unused")
	private static final String TEMPLATE_NAME = "freemaker-domain";

	public static void process(Context ctx, Table table) throws Exception {
		StringBuilder sb = new StringBuilder(ctx.getMapper());
		sb.append(JavaBeanUtils.splitString(table.getPackageName()));
		sb.append("/domain/");
		sb.append(table.getDomainName()).append("Domain.java");
		FreemarkerUtils.write(sb.toString(), FreemarkerUtils.process("freemaker-domain", table));
	}
}
